
class DubleLinklist
{
public:
    using ElementType = int;
    DubleLinklist() : size(0)
    {
        head = tail = new Node(0);
    }
    DubleLinklist(const DubleLinklist &list)
    {
        size = list.size;
        head = tail = new Node(0);
        Node *tp = head;
        Node *ltp = list.head->next;
        while(ltp != nullptr)
        {
            Node *newNode = new Node(ltp->data);
            tp->next = newNode;
            newNode->prev = tp;
            tp = tp->next;
            ltp = ltp->next;
        }
        tail = tp;
    }
    

private:
    struct Node
    {
        Node(const ElementType &value)
        {
            this->data = data;
            prev = next = nullptr;
        }
        ElementType data;
        Node *prev;
        Node *next;
    };
    Node *head;
    Node *tail;
    size_t size;
};